/* Copyright (c) 2012-2013, Xiaomi corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <linux/mfd/pm8xxx/pm8921-bms.h>

static struct single_row_lut fcc_temp = {
	.x		= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 60},
	.y		= {3116, 3110, 3106, 3103, 3101, 3099, 3097, 3096, 3095, 3091, 3080},
	.cols		= 11
};

static struct single_row_lut fcc_sf = {
	.x		= {0},
	.y		= {100},
	.cols		= 1
};

static struct sf_lut rbatt_sf = { 
        .rows		= 28, 
        .cols		= 11,
        /* row_entries are temperature */
        .row_entries	= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 60},
        .percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
        .sf		= {
{810,351,196,159,135,118,108,100,96,91,94},
{834,375,210,169,141,123,111,102,97,92,94},
{842,372,214,174,147,127,115,106,100,95,95},
{861,365,211,175,148,131,117,108,102,96,96},
{871,371,209,175,153,136,123,113,106,99,98},
{877,371,209,173,152,139,127,118,111,102,100},
{886,372,207,169,146,133,126,120,115,107,102},
{903,372,206,166,142,127,118,112,109,107,105},
{927,375,205,166,140,123,113,105,100,96,98},
{958,378,207,167,140,123,111,104,98,94,96},
{999,385,208,168,141,124,112,104,98,94,96},
{1052,395,211,169,142,125,113,106,100,95,97},
{1110,409,217,172,145,127,115,107,102,97,98},
{1173,427,225,178,148,129,117,109,103,99,100},
{1244,451,236,185,151,130,116,107,100,95,97},
{1324,483,248,191,154,130,115,106,99,94,97},
{1427,531,258,197,157,132,117,107,100,96,98},
{1591,617,273,205,162,135,118,108,101,96,97},
{1128,477,236,183,149,128,114,105,99,94,97},
{1185,488,239,184,150,129,115,106,100,95,98},
{1261,511,246,190,154,131,117,108,102,97,100},
{1356,542,259,197,159,136,120,110,104,98,102},
{1519,590,276,208,166,140,123,112,106,100,103},
{1992,663,296,219,171,142,124,112,105,99,100},
{2954,797,326,232,178,145,126,113,105,99,101},
{5280,1158,396,269,196,156,132,117,109,101,102},
{13517,3222,598,364,245,182,148,128,118,106,105},
{45627,12709,2208,913,440,290,228,209,222,138,116},
        }
};

static struct pc_temp_ocv_lut pc_temp_ocv = {
	.rows		= 29,
	.cols		= 11,
	.temp		= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 60},
	.percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
	.ocv		= {
				{4184, 4182, 4181, 4181, 4180, 4179, 4178, 4177, 4176, 4173, 4168},
				{4083, 4100, 4107, 4109, 4110, 4110, 4110, 4110, 4110, 4108, 4106},
				{4006, 4049, 4062, 4065, 4066, 4066, 4066, 4066, 4066, 4064, 4061},
				{3954, 3997, 4014, 4018, 4021, 4022, 4023, 4024, 4024, 4024, 4021},
				{3915, 3953, 3972, 3978, 3982, 3984, 3985, 3986, 3987, 3988, 3985},
				{3877, 3921, 3937, 3943, 3949, 3952, 3954, 3955, 3955, 3955, 3953},
				{3844, 3887, 3902, 3908, 3914, 3919, 3922, 3924, 3925, 3926, 3924},
				{3817, 3856, 3870, 3875, 3880, 3885, 3889, 3893, 3895, 3897, 3896},
				{3796, 3830, 3843, 3847, 3851, 3854, 3857, 3859, 3862, 3865, 3865},
				{3779, 3807, 3820, 3824, 3827, 3829, 3831, 3832, 3833, 3834, 3833},
				{3763, 3788, 3801, 3805, 3807, 3809, 3810, 3812, 3812, 3812, 3811},
				{3746, 3774, 3785, 3789, 3791, 3793, 3795, 3796, 3796, 3797, 3795},
				{3728, 3762, 3774, 3776, 3779, 3781, 3782, 3783, 3784, 3784, 3782},
				{3711, 3749, 3764, 3767, 3769, 3771, 3772, 3773, 3774, 3774, 3770},
				{3694, 3734, 3754, 3758, 3760, 3761, 3761, 3762, 3761, 3759, 3752},
				{3677, 3716, 3741, 3745, 3747, 3747, 3747, 3746, 3744, 3739, 3727},
				{3657, 3696, 3721, 3726, 3727, 3727, 3727, 3726, 3724, 3719, 3706},
				{3632, 3672, 3690, 3694, 3697, 3698, 3699, 3698, 3697, 3693, 3681},
				{3595, 3643, 3658, 3661, 3664, 3668, 3670, 3671, 3671, 3668, 3657},
				{3582, 3634, 3650, 3655, 3660, 3663, 3665, 3667, 3667, 3665, 3654},
				{3567, 3622, 3642, 3648, 3653, 3657, 3660, 3662, 3662, 3660, 3650},
				{3549, 3607, 3631, 3637, 3643, 3648, 3652, 3654, 3655, 3652, 3640},
				{3527, 3585, 3610, 3618, 3624, 3630, 3634, 3636, 3637, 3633, 3619},
				{3498, 3553, 3576, 3582, 3588, 3595, 3599, 3601, 3601, 3597, 3582},
				{3458, 3506, 3525, 3531, 3537, 3544, 3549, 3552, 3552, 3549, 3533},
				{3402, 3440, 3456, 3462, 3470, 3479, 3486, 3488, 3489, 3486, 3471},
				{3321, 3347, 3363, 3371, 3381, 3392, 3400, 3404, 3405, 3403, 3388},
				{3198, 3211, 3226, 3234, 3247, 3262, 3272, 3276, 3278, 3278, 3262},
				{3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000}
	}
};

struct pm8921_bms_battery_data sony_3000_data = {
	.fcc			= 3210,
	.fcc_temp_lut		= &fcc_temp,
	.fcc_sf_lut		= &fcc_sf,
	.pc_temp_ocv_lut	= &pc_temp_ocv,
	.rbatt_sf_lut		= &rbatt_sf,
	.default_rbatt_mohm	= 142,
};
